/*
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see http://www.gnu.org/licenses/. 
 *
 *  Authors:
 *  	Albert Marieges Garcia
 *  	Álex Pardo Fernández
 *  	Enric Mayas Márquez
 *  	Juan Carlos Calvo Tejedor
 *  	Marc Gironés Dezsényi
 *  
 *  Contact:
 *  	bcn.tours.android@gmail.com
 *  Webpage:
 *  	bcntours.co.cc
 *
 */
package com.BCNTours.Vista;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.LayoutInflater;
import android.view.View;

import com.BCNTours.R;

/**
 * View that pops out the very first time you open the application, to ask for the language you will want to use as default. 
 *
 */
public class LanguageSetting extends Activity{
	/*Attributions*/
//    private ApplicationData applicationData;
	
	/** 
     * Called when the activity is first created. 
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {     
        super.onCreate(savedInstanceState);
        setContentView(R.layout.language_setting);
        
        //Animation of the screen
        @SuppressWarnings("unused")
		LayoutInflater mInflater = (LayoutInflater) getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    }
    
    
    /**
     * BtnActionListener of the main menu
     */
    public void btnLanguageSettingPerformed(View view){
    	@SuppressWarnings("unused")
		Intent intent = new Intent();
    	SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    	Editor editor;
    	switch(view.getId()){
			//Button Spanish
			case R.id.btnSpanish:
				editor = prefs.edit(); 
				editor.putInt(Preferences.PREF_LANG, 1); 
				editor.commit();
				break;
				
			//Button Catala
			case R.id.btnCatalan:
				editor = prefs.edit(); 
				editor.putInt(Preferences.PREF_LANG, 2); 
				editor.commit();
				break;
				
			//Button English
			case R.id.btnEnglish:
				editor = prefs.edit(); 
				editor.putInt(Preferences.PREF_LANG, 3); 
				editor.commit();
				break;
				
    	}
    	
		Intent i = new Intent(LanguageSetting.this, SplashScreenActivity.class);
		startActivity(i);
		finish();
    }
}
